package com.aiju.cash.ui.account.entity;

import com.aiju.cash.ui.account.AccountCreatActivity;
import com.aiju.utils.DateUtil;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author: 佐为
 * @date: 2017-04-05 16:53
 * @version: V1.0
 * @Description: 账目列表实体
 */
public class ItemList {


    private List<Sum> sum;

    private List<DateItem> list;


    public List<Sum> getSum() {
        return sum;
    }

    public void setSum(List<Sum> sum) {
        this.sum = sum;
    }

    public List<DateItem> getList() {
        return list;
    }

    public void setList(List<DateItem> list) {
        this.list = list;
    }

    public List<Item> getAllItem() {
        List<Item> items = new ArrayList<>();
        for (DateItem dateItem : list) {
            items.addAll(dateItem.getList());
        }
        return items;
    }

    public class DateItem {

        private String date;
        private Daysum daysum;
        private List<Item> list;

        public Daysum getDaysum() {
            return daysum;
        }

        public void setDaysum(Daysum daysum) {
            this.daysum = daysum;
        }

        public String getYMdate() {
            return DateUtil.getStringByFormat(getAlldate(), DateUtil.dateFormatYM_C);
        }

        public String getAlldate() {
            return date + " 00:00:00";
        }

        public String getDay() {
            return date.substring(8, 10);
            //return "a";
        }

        public String getIn() {
            Double in = 0.00;
            for (Item item : list) {
                if (item.getType().equals("1")) {
                    in += Double.valueOf(item.getMoney());
                }
            }
            return String.valueOf(in);
        }

        public String getOut() {
            Double out = 0.00;
            for (Item item : list) {
                if (item.getType().equals("2")) {
                    out += Double.valueOf(item.getMoney());
                }
            }
            return String.valueOf(out);
        }

        public String getDate() {
            return date;
        }

        public void setDate(String date) {
            this.date = date;
        }

        public List<Item> getList() {
            return list;
        }

        public void setList(List<Item> list) {
            this.list = list;
        }

    }

    /**
     * 当天收支总和
     */
    public class Daysum {
        private String cost;//支出
        private String income;//收入

        public String getCost() {
            return cost;
        }

        public void setCost(String cost) {
            this.cost = cost;
        }

        public String getIncome() {
            return income;
        }

        public void setIncome(String income) {
            this.income = income;
        }
    }

    public class Item implements Serializable {
        private String id;
        private String accountId;
        private String categoryName;
        private String money;
        private String type;
        private String accountType;
        private String remark;
        private String operatorName;
        private String operatorId;
        private String imageType;
        private String date;

        private String createDate;
        private String modifyDate;

        public String getCreateDate() {
            return createDate;
        }

        public void setCreateDate(String createDate) {
            this.createDate = createDate;
        }

        public String getModifyDate() {
            return modifyDate;
        }

        public void setModifyDate(String modifyDate) {
            this.modifyDate = modifyDate;
        }

        public String getAccountId() {
            return accountId;
        }

        public void setAccountId(String accountId) {
            this.accountId = accountId;
        }

        public String getAccountType() {
            return AccountCreatActivity.msg.get(Integer.valueOf(accountType) - 1);
        }

        public void setAccountType(String accountType) {
            this.accountType = accountType;
        }

        public String getCategoryName() {
            return categoryName;
        }

        public void setCategoryName(String categoryName) {
            this.categoryName = categoryName;
        }

        public String getDate() {
            return date;
        }

        public void setDate(String date) {
            this.date = date;
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getImageType() {
            return imageType;
        }

        public void setImageType(String imageType) {
            this.imageType = imageType;
        }

        public String getMoney() {
            return type.equals("1") ? money : "-" + money;
        }

        public String getSimpleMoney() {
            return money;
        }

        public void setMoney(String money) {
            this.money = money;
        }

        public String getOperatorId() {
            return operatorId;
        }

        public void setOperatorId(String operatorId) {
            this.operatorId = operatorId;
        }

        public String getOperatorName() {
            return operatorName;
        }

        public void setOperatorName(String operatorName) {
            this.operatorName = operatorName;
        }

        public String getRemark() {
            return remark;
        }

        public void setRemark(String remark) {
            this.remark = remark;
        }

        public String getType() {
            return type;
        }

        public String getTypeString() {
            return type.equals("1") ? "收入" : "支出";
        }

        public void setType(String type) {
            this.type = type;
        }


    }

    public class Sum {

        private String money;
        private int type; //1：收 2：支

        public int getType() {
            return type;
        }

        public void setType(int type) {
            this.type = type;
        }

        public String getMoney() {
            return money;
        }

        public void setMoney(String money) {
            this.money = money;
        }

    }
}
